/*************************************************************************
    > File Name: devled.c
    > Author: klmyt
    > Created Time: 2025年02月08日 星期六 09时17分43秒
 ************************************************************************/

#include "devled.h"

typedef struct devled {
	int gpio;
	int index;
	char* name;
}devled_t;

typedef struct ledinfo {
	int size;
	devled_t* pleds;
}ledinfo_t;

static devled_t leds[] = {
	{.gpio = PAD_GPIO_C + 12, .name= "led1", .index = 0},
	{.gpio = PAD_GPIO_C + 11, .name= "led2", .index = 1},
	{.gpio = PAD_GPIO_C + 7,  .name= "led3", .index = 2},
	{.gpio = PAD_GPIO_B + 26, .name= "led4", .index = 3}
};

static ledinfo_t ledinfo = {
	.pleds = leds,
	.size = ARRAY_SIZE(leds)
};


static void devled_release(struct device* dev) {
	printk("%s: %d # %s # %s \n ", __func__, __LINE__, __DATE__, __TIME__);
};

static struct platform_device pd = {
	
	.name = "myled",
	.id = -1,
	.dev = {
		.platform_data = &ledinfo,
		.release = devled_release
	}
};


int devled_init(void){

	platform_device_register(&pd);

	return 0;
};

void devled_exit(void){

	platform_device_unregister(&pd);

};

module_init(devled_init);
module_exit(devled_exit);
MODULE_LICENSE("GPL");

